<template>
    <div>
        <el-row>
            <el-col :span="21"><el-input v-model="input" placeholder="请输入" @keydown.enter="add()"/></el-col>
            <el-col :span="3"><el-button type="success" @click="add()">添加</el-button></el-col>
        </el-row>
    </div>
</template>
<script>
export default {
    data() {
        return {
            input:''
        }
    },
    methods: {
        add(){
            if(this.input===''){
                this.$message({
                    message:'不能为空',
                    type:'warning'
                })
            }
            else{
                this.$emit('add',this.input)
                this.input=''
            }
        }
    },
}
</script>